-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ExhaustiveRefasterTypeMigration
check
#770
Introduce ExhaustiveRefasterTypeMigration
check
#770
Conversation
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
1 similar comment
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
Kudos, SonarCloud Quality Gate passed! |
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
0da94ff
to
c085f2d
Compare
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
Kudos, SonarCloud Quality Gate passed! |
c085f2d
to
3cfa724
Compare
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 3 New issues |
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
1 similar comment
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing stands out to me 🚀
...ntrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationListing.java
Show resolved
Hide resolved
* com.google.errorprone.util.Signatures#prettyMethodSignature(com.sun.tools.javac.code.Symbol.ClassSymbol, | ||
* com.sun.tools.javac.code.Symbol.MethodSymbol)}. | ||
*/ | ||
String[] unmigratedMethods() default {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intellij flags this as a spelling mistake 🤔
Maybe:
String[] unmigratedMethods() default {}; | |
String[] nonMigratedMethods() default {}; |
or
String[] unmigratedMethods() default {}; | |
String[] notMigratedMethods() default {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unmigrated
is an actual word, so we can also tell IntelliJ to ignore it :). Would be my preference.
" of = Util.class,", | ||
" unmigratedMethods = {", | ||
" \"publicStaticVoidMethod()\",", | ||
" \"publicStringMethodWithArg(int)\",", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to test overloaded methods here ?
" \"publicStringMethodWithArg(int)\",", | |
" \"publicStringMethodWithArg(int)\",", | |
" \"publicStringMethodWithArg(String)\",", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which brings me to my question on why do we need to flag all the variants of the overloaded method ? 🤔
Is it wrong to assume that if a rule does not apply to one type set of arguments, will not be applied to other ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice idea to test overloads; let me add a commit for that.
As for why we should flag all variants: due to how Refaster works, each variant needs to be matched explicitly. It may be that n
out of m > n
overloads are covered; by explicitly listing the remainder it'll be easier to determine which rules are missing.
3cfa724
to
b969b95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased and added two small commits.
...ntrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationListing.java
Show resolved
Hide resolved
" of = Util.class,", | ||
" unmigratedMethods = {", | ||
" \"publicStaticVoidMethod()\",", | ||
" \"publicStringMethodWithArg(int)\",", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice idea to test overloads; let me add a commit for that.
As for why we should flag all variants: due to how Refaster works, each variant needs to be matched explicitly. It may be that n
out of m > n
overloads are covered; by explicitly listing the remainder it'll be easier to determine which rules are missing.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
I'll rebase this branch and move the check to the new |
b969b95
to
d71244f
Compare
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
1 similar comment
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing check 🚀 !
* indicated type. | ||
*/ | ||
// XXX: Add support for `#unmigratedFields()`. | ||
// XXX: Consider making this annotation `@Repeatable`, for cases where a single Refaster rules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// XXX: Consider making this annotation `@Repeatable`, for cases where a single Refaster rules | |
// XXX: Consider making this annotation `@Repeatable`, for cases where a single Refaster rule |
* com.google.errorprone.util.Signatures#prettyMethodSignature(com.sun.tools.javac.code.Symbol.ClassSymbol, | ||
* com.sun.tools.javac.code.Symbol.MethodSymbol)}. | ||
*/ | ||
String[] unmigratedMethods() default {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unmigrated
is an actual word, so we can also tell IntelliJ to ignore it :). Would be my preference.
// XXX: Add support for `#unmigratedFields()`. | ||
// XXX: Consider making this annotation `@Repeatable`, for cases where a single Refaster rules | ||
// collection migrates away from multiple types. | ||
@Target(ElementType.TYPE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really sure what the best sorting would be here, but we have the annotation sorting on method level. We could swap them here as well.
// XXX: Consider making this annotation `@Repeatable`, for cases where a single Refaster rules | ||
// collection migrates away from multiple types. | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.SOURCE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Retention(RetentionPolicy.SOURCE) | |
@Retention(SOURCE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don''t really lose any context with this? Do we want to add this to the StaticImport
check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we don't lose much, but the current variant does seem a bit clearer to me. Since this annotation will only be present on a separate line in (almost always) small files, I don't think there's much point in forcing a static import here. Internally only 2 out of 67 usages statically import it.
" }", | ||
" }", | ||
"", | ||
" // BUG: Diagnostic contains: The set of unmigrated methods listed by the `@TypeMigration`", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we simply use "// BUG: Diagnostic contains:",
here? That already signals that we are just flagging this, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check emits two kinds of messages, so for each violation I'm asserting that the correct message is emitted.
eb7c402
to
c7f03c7
Compare
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
The new `@TypeMigration` annotation can be placed on Refaster rule collections to indicate that they migrate most or all public methods of an indicated type. The new check validates the claim made by the annotation.
c7f03c7
to
3e54b8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased and added a small commit. Will merge once built.
@Retention(RetentionPolicy.SOURCE) | ||
@Target(ElementType.TYPE) | ||
public @interface TypeMigration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the topic of annotation sorting: makes sense. We should extend LexicographicalAnnotationListing
; will add a comment.
// XXX: Consider making this annotation `@Repeatable`, for cases where a single Refaster rules | ||
// collection migrates away from multiple types. | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.SOURCE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we don't lose much, but the current variant does seem a bit clearer to me. Since this annotation will only be present on a separate line in (almost always) small files, I don't think there's much point in forcing a static import here. Internally only 2 out of 67 usages statically import it.
" }", | ||
" }", | ||
"", | ||
" // BUG: Diagnostic contains: The set of unmigrated methods listed by the `@TypeMigration`", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check emits two kinds of messages, so for each violation I'm asserting that the correct message is emitted.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
Quality Gate passedIssues Measures |
Suggested commit message:
This will help flag new to-be-migrated methods any time the JUnit or TestNG dependency is upgraded. (This PR also flags that
TestNGToAssertJRules
is no longer nearly as exhaustive as it once was. Resolving that will be deferred to a separate PR. I started a TestNG and JUnit branch. That said, given the repetition involved, perhaps introducing a bug checker or two is in order.)